﻿// ------------------------------------------------------------------------------------------------
// summary: This file contains individual parsers as plugins for parsing system level 
//			features like control-flow e..g if, while, for, try, break, continue, return etc.
// version: 0.9.8.10
// author:  kishore reddy
// date:	Wednesday, December 19, 2012
// ------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Collections;

using ComLib.Lang.Core;
using ComLib.Lang.AST;
using ComLib.Lang.Types;
using ComLib.Lang.Helpers;
using ComLib.Lang.Parsing;

namespace ComLib.Lang.Parsing
{
	
		// Plugin: 15 - NewExpr
		public class NewPlugin : ExprPlugin
		{
			public NewPlugin()
			{				
				this.ConfigureAsSystemStatement(false, false, "");
				this.Precedence = 1;
			}

			public override Expr Parse()
			{
				return this._exprParser.OnParseNew();
			}


			public override void OnParseComplete(AstNode node)
			{
				var expr = node as Expr;
				this._exprParser.OnParseNewComplete(expr);
			}
		}
	
		// Plugin: 18 - BreakExpr
		public class BreakPlugin : ExprPlugin
		{
			public BreakPlugin()
			{				
				this.ConfigureAsSystemStatement(false, true, "break");
				this.Precedence = 1;
			}

			public override Expr Parse()
			{
				return this._exprParser.OnParseBreak();
			}


			public override void OnParseComplete(AstNode node)
			{
				var expr = node as Expr;
				this._exprParser.OnParseBreakComplete(expr);
			}
		}
	
		// Plugin: 19 - ContinueExpr
		public class ContinuePlugin : ExprPlugin
		{
			public ContinuePlugin()
			{				
				this.ConfigureAsSystemStatement(false, true, "continue");
				this.Precedence = 1;
			}

			public override Expr Parse()
			{
				return this._exprParser.OnParseContinue();
			}


			public override void OnParseComplete(AstNode node)
			{
				var expr = node as Expr;
				this._exprParser.OnParseContinueComplete(expr);
			}
		}
	
		// Plugin: 20 - ForEachExpr
		public class ForEachPlugin : ExprPlugin
		{
			public ForEachPlugin()
			{				
				this.ConfigureAsSystemStatement(true, false, "for");
				this.Precedence = 1;
			}

			public override Expr Parse()
			{
				return this._exprParser.OnParseForEach();
			}


			public override void OnParseComplete(AstNode node)
			{
				var expr = node as Expr;
				this._exprParser.OnParseForEachComplete(expr);
			}
		}
	
		// Plugin: 21 - ForExpr
		public class ForPlugin : ExprPlugin
		{
			public ForPlugin()
			{				
				this.ConfigureAsSystemStatement(true, false, "for");
				this.Precedence = 1;
			}

			public override Expr Parse()
			{
				return this._exprParser.OnParseFor();
			}


			public override void OnParseComplete(AstNode node)
			{
				var expr = node as Expr;
				this._exprParser.OnParseForComplete(expr);
			}
		}
	
		// Plugin: 22 - FunctionDeclareExpr
		public class FunctionDeclarePlugin : ExprPlugin
		{
			public FunctionDeclarePlugin()
			{				
				this.ConfigureAsSystemStatement(true, false, "function");
				this.Precedence = 1;
			}

			public override Expr Parse()
			{
				return this._exprParser.OnParseFunctionDeclare();
			}


			public override void OnParseComplete(AstNode node)
			{
				var expr = node as Expr;
				this._exprParser.OnParseFunctionDeclareComplete(expr);
			}
		}
	
		// Plugin: 23 - IfExpr
		public class IfPlugin : ExprPlugin
		{
			public IfPlugin()
			{				
				this.ConfigureAsSystemStatement(true, false, "if");
				this.Precedence = 1;
			}

			public override Expr Parse()
			{
				return this._exprParser.OnParseIf();
			}


			public override void OnParseComplete(AstNode node)
			{
				var expr = node as Expr;
				this._exprParser.OnParseIfComplete(expr);
			}
		}
	
		// Plugin: 24 - LambdaExpr
		public class LambdaPlugin : ExprPlugin
		{
			public LambdaPlugin()
			{				
				this.ConfigureAsSystemStatement(true, false, "function");
				this.Precedence = 1;
			}

			public override Expr Parse()
			{
				return this._exprParser.OnParseLambda();
			}


			public override void OnParseComplete(AstNode node)
			{
				var expr = node as Expr;
				this._exprParser.OnParseLambdaComplete(expr);
			}
		}
	
		// Plugin: 25 - ReturnExpr
		public class ReturnPlugin : ExprPlugin
		{
			public ReturnPlugin()
			{				
				this.ConfigureAsSystemStatement(false, true, "return");
				this.Precedence = 1;
			}

			public override Expr Parse()
			{
				return this._exprParser.OnParseReturn();
			}


			public override void OnParseComplete(AstNode node)
			{
				var expr = node as Expr;
				this._exprParser.OnParseReturnComplete(expr);
			}
		}
	
		// Plugin: 26 - ThrowExpr
		public class ThrowPlugin : ExprPlugin
		{
			public ThrowPlugin()
			{				
				this.ConfigureAsSystemStatement(false, true, "throw");
				this.Precedence = 1;
			}

			public override Expr Parse()
			{
				return this._exprParser.OnParseThrow();
			}


			public override void OnParseComplete(AstNode node)
			{
				var expr = node as Expr;
				this._exprParser.OnParseThrowComplete(expr);
			}
		}
	
		// Plugin: 27 - TryCatchExpr
		public class TryCatchPlugin : ExprPlugin
		{
			public TryCatchPlugin()
			{				
				this.ConfigureAsSystemStatement(true, false, "try");
				this.Precedence = 1;
			}

			public override Expr Parse()
			{
				return this._exprParser.OnParseTryCatch();
			}


			public override void OnParseComplete(AstNode node)
			{
				var expr = node as Expr;
				this._exprParser.OnParseTryCatchComplete(expr);
			}
		}
	
		// Plugin: 28 - WhileExpr
		public class WhilePlugin : ExprPlugin
		{
			public WhilePlugin()
			{				
				this.ConfigureAsSystemStatement(true, false, "while");
				this.Precedence = 1;
			}

			public override Expr Parse()
			{
				return this._exprParser.OnParseWhile();
			}


			public override void OnParseComplete(AstNode node)
			{
				var expr = node as Expr;
				this._exprParser.OnParseWhileComplete(expr);
			}
		}
	}

			